home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / CONSTRAI / CONSTRAI.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  8.0 KB  |  194 lines

  1.  
  2. package sub_arctic.constraints;
  3.  
  4. import sub_arctic.lib.interactor;
  5.  
  6. import java.util.Vector;
  7.  
  8. /**
  9.  * Interface for objects that provide an implementation for constraints.  
  10.  * These object understand how to encode and decode an integer encoding of 
  11.  * a constraint (or maintain such a coding inside themselves), and use that 
  12.  * to perform operations such as evaluate the constraint, determine if it 
  13.  * depends upon a particular value, produce a human readable rendition of 
  14.  * the constraint, etc. <p>
  15.  *
  16.  * For constraint implementations that do not encode the constraints inside
  17.  * the object, there is typically only one instance of each constraint 
  18.  * implementation which is shared by all constraints encoded in the same form
  19.  * (this is true for example of std_constraint_impl).<p>
  20.  *
  21.  * @see constraints.std_constraint_impl
  22.  * @author Scott Hudson
  23.  */
  24. public interface constraint_impl {
  25.  
  26.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  27.  
  28.   /** 
  29.    * Create a human readable string corresponding to the given constraint
  30.    * encoding.
  31.    *
  32.    * @param int enc    the constraint encoding
  33.    * @param int orient the orientation of the constraint
  34.    * @return String a human readable string for the constraint
  35.    */
  36.   public String str_for(int enc, int orient);
  37.  
  38.   /** 
  39.    * Create a terse human readable string corresponding to the given constraint
  40.    * encoding.
  41.    *
  42.    * @param int enc the constraint encoding
  43.    * @param int orient the orientation of the constraint
  44.    * @return String a human readable string for the constraint
  45.    */
  46.   public String tag_for(int enc, int orient);
  47.  
  48.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  49.  
  50.   /** 
  51.    * Determine if a given constraint encoding represents "none" (i.e., that
  52.    * no constraint is to be applied).<p>
  53.    * 
  54.    * @param int enc  the encoding for the constraint.
  55.    * @return boolean true if the encoding represents "none"
  56.    */
  57.   public boolean is_none(int enc);
  58.  
  59.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  60.  
  61.   /** 
  62.    * Determine if a given constraint encoding represents an external
  63.    * (aka heavyweight) constraint.<p>
  64.    * 
  65.    * @param int enc  the encoding for the constraint.
  66.    * @return boolean true if the encoding indicates an external constraint
  67.    */
  68.   public boolean is_external(int enc);
  69.  
  70.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  71.  
  72.   /** 
  73.    * Evaluate an encoded constraint (under a given orientation).  The 
  74.    * constraint is being applied to the given part of the given object (i.e. 
  75.    * the constr_part part of the constr_obj object).  The encoding typically 
  76.    * will designate parameter values relative to that object (i.e. the width 
  77.    * of the parent of the object). <p>
  78.    *
  79.    * @param int        enc         the encoding of the constraint
  80.    * @param interactor constr_obj  the object being constrained
  81.    * @param int        constr_part the part being constrained
  82.    * @param int        orient      the orientation of the constraint
  83.    * @return int the result of the evaluation
  84.    */
  85.   public int eval(
  86.     int        enc,        
  87.     interactor constr_obj, 
  88.     int        constr_part,
  89.     int        orient);
  90.  
  91.    //had:
  92.    //* @exception bad_value if the encoding, or constrained object/part are 
  93.    //*                      malformed
  94.  
  95.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  96.  
  97.   /** Test whether the given encoded constraint depends on the indicated 
  98.    *  neighboring object and part.  The constraint is attached to the 
  99.    *  constr_obj object and this test is expressed relative to that object.  
  100.    *  The object and part that we determine dependency upon is encoded in
  101.    *  test_which_obj and test_which_part.  For tests of child objects, an
  102.    *  indication of the index of that child is also given.<p>
  103.    *
  104.    *  If this is an "external" constraint that maintains its own dependency
  105.    *  edges and works through the external notification system, then this 
  106.    *  method may safely return false in all cases. <p>
  107.    *
  108.    * @param int        enc             The encoding for the constraint.
  109.    * @param interactor constr_obj      The object the constraint is attached to
  110.    * @param int        test_which_obj  The neighboring object we are asking 
  111.    *                                   about.  This can be one of the values 
  112.    *                                   OBJCODE_SELF, OBJCODE_PARENT, 
  113.    *                                   OBJCODE_SOME_CHILD, 
  114.    *                                   OBJCODE_PREV_SIBLING, or 
  115.    *                                   OBJCODE_NEXT_SIBLING.  
  116.    * @param int        test_which_part The part we are asking about.
  117.    * @param int        nth_child       for SOME_CHILD, this provides the index
  118.    *                       of the child (and is ignored otherwise).
  119.    * @param int        orient          Orientation of the constraint.  This 
  120.    *                                   should be HORIZONTAL or VERTICAL.
  121.    * @return boolean whether the given constraint depends upon the given value
  122.    */
  123.   public boolean depends_on(
  124.     int        enc, 
  125.     interactor constr_obj,
  126.     int        which_obj, 
  127.     int        which_part, 
  128.     int        nth_child,
  129.     int        orient);
  130.  
  131.    //had:
  132.    //* @exception bad_value if one of the parameters has an unrecognized value
  133.  
  134.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  135.  
  136.   /**
  137.    * Extract the set of objects/parts that a constraint depends on.  This
  138.    * produces a Vector with pairs of entries, the first being an interactor,
  139.    * and the second being an Integer which is the part number of that 
  140.    * interactor that is depended upon.<p>
  141.    *
  142.    * @param int        enc        encoding value for the constraint in question.
  143.    * @param interactor constr_obj the object the constraint is attached to 
  144.    *                              (hence its referents are relative to).
  145.    * @param int        orient     Orientation of the constraint.  This
  146.    *                              should be HORIZONTAL or VERTICAL.
  147.    * @return Vector containing pairs of objects, the first being an interactor
  148.    *                which is depended upon, and the second being an Integer
  149.    *                giving the part number of the part depended upon.
  150.    */
  151.   public Vector depend_list(int enc, interactor constr_obj, int orient);
  152.  
  153.    //had:
  154.    //* @exception bad_value if the encoding value is not valid.
  155.  
  156.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  157.  
  158.   /** 
  159.    * Extract the dependencies that are implicit in the particular operation
  160.    * encoded in the given standard constraint encoding. <p>
  161.    * 
  162.    * @param int        enc        encoding value for the constraint in question.
  163.    * @param interactor constr_obj the object the constraint is attached to 
  164.    *                              (hence its referents are relative to).
  165.    * @param int        orient     Orientation of the constraint.  This
  166.    *                              should be HORIZONTAL or VERTICAL.
  167.    * @return Vector containing pairs of objects, the first being an interactor
  168.    *                which is depended upon, and the second being an Integer
  169.    *                giving the part number of the part depended upon.
  170.    */
  171.   public Vector implicit_depend_list(int enc, interactor constr_obj,int orient);
  172.  
  173.    //had:
  174.    //* @exception bad_value if the encoding value is not valid.
  175.  
  176.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  177. }
  178. /*=========================== COPYRIGHT NOTICE ===========================
  179.  
  180. This file is part of the subArctic user interface toolkit.
  181.  
  182. Copyright (c) 1996 Scott Hudson and Ian Smith
  183. All rights reserved.
  184.  
  185. The subArctic system is freely available for most uses under the terms
  186. and conditions described in 
  187.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  188. and appearing in full in the lib/interactor.java source file.
  189.  
  190. The current release and additional information about this software can be 
  191. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  192.  
  193. ========================================================================*/
  194.